#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
int main(int argc, char const *argv[])
{
printf("创建进程开始\n");
    pid_t pid = fork();
    printf("fork后\n");
    if(pid<0){
        printf("创建进程失败\n");
        return -1;
    }else if (pid==0)
    {
        printf("我是子进程,我的pid是%d\n",getpid());
        char *path = "/bin/ping";
        char *argv[] = {path,"-c","3","www.baidu.com",NULL};
        int result = execve(path,argv,NULL);
        if(result==-1){
            printf("execve执行失败\n");
        }
        printf("heiheiheiheihei\n");
    }else{
        printf("我是父进程,我的pid是%d\n",getpid());
        int fstatus;
        waitpid(pid,&fstatus,0);
        printf("父进程结束=..........fstatus=%d\n",fstatus);
    }
    printf("进程即将结束%d\n",getpid());

    return 0;
}
